<!-- @@master  = ../../../tpl/base.html-->
<!-- @@block  =  head-->
<style media="screen">
ul.post-view li{
  text-align: center;
  padding: 10px 20px;
  width: calc(100% / 3 - 10px);
  width: -webkit-calc(100% / 3 - 10px);
  margin: 0px 5px;
  float: left;
}
ul.post-view li:hover, ul.post-view li.active{
  border-radius: 5px;
  color: white;
}
</style>
<!-- @@close-->
<!-- @@block  =  content-->
<section class="panel panel-default">
<header class="panel-heading">
  广告审核
<span class="tools pull-right">
    <a class="fa fa-chevron-down" href="javascript:;"></a>
    <a class="fa fa-times" href="javascript:;"></a>
</span>
</header>
<div class="panel-body">
  <ul class="post-view" style="width:450px">
      <li class="active" data-state="0">正在审核：<span class="badge badge-warning"></span></li>
      <li data-state="1">审核成功：<span class="badge badge-success"></span></li>
      <li data-state="2">审核失败：<span class="badge badge-important"></span></li>
  </ul>
  <div>
    <table class="display table table-bordered" id="verify-table"></table>
  </div>
</div>
</section>
<!-- @@close-->
<!-- @@block  =  foot-->
<script type="text/javascript">
(function() {
    "use strict";
    $(document).on("click","#add-ad",function(data){
        window.location.href = "/ad/addAd.html#ads";
    });
    $(document).on("click",".post-view >li",function(){
      var state = $(this).data("state");
      oTable.fnClearTable();
      $(".post-view >li").removeClass("active");
      $(this).addClass("active");
      oTable.fnAddData(verify[state]);
    });
    var oTable = $('#verify-table').dataTable({
      "bSort":false,
      "bProcessing":true,
      "bAutoWidth":false,
      "aoColumns": [
          {"sTitle": "应用名称","mData": "app_store_name"},
          {"sTitle": "关键词","mData": "keyword"},
          {"sTitle": "排名","mData": "rank"},
          {"sTitle": "开始时间","mData": "time_begin"},
          {"sTitle": "结束时间","mData": "time_end"},
          {"sTitle": "投放量","mData": "num_plan"},
      ]
    });
    var time = new Date();
    time.setTime(time.getTime()+30*24*3600*1000);
    var date = myHttp.getDate(time);
    //var date = time.getFullYear()+"-"+(time.getMonth() + 1)+"-"+time.getDate();
    var company_id = JSON.parse(sessionStorage.getItem("user")).id;
    var verify = {0:[],1:[],2:[]};
    myHttp.getJSON(myHttp.dataUrl+"launches/keyword/?time_begin=2016-07-20&time_end="+date+"&company_id="+company_id+"&state=-2",function(data){
        oTable.fnClearTable();
        for(var i=0;i<data.length;i++){
          var item = data[i];
          if(!verify[item.state]){
            verify[item.state] = [];
          }
          verify[item.state].push(item);
        }
        $(".badge-warning").html(verify[0].length);
        $(".badge-success").html(verify[1].length);
        $(".badge-important").html(verify[2].length);
        oTable.fnAddData(verify[0]);
    });
})(jQuery);
</script>
<!-- @@close-->
